import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/deskTop'
  },
  {
    path: '/deskTop',
    name: 'deskTop',
    component: () => import('@/views/deskTop/deskTop.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

// 路由守卫
router.beforeEach((to: any, from: any) => {
  // if (to.path === '/login' || to.path === '/') {
  //   if (window.sessionStorage.getItem('userid')) {
  //     Toast('已回退到登录页面，退出登录状态')
  //     window.sessionStorage.removeItem('userid')
  //     window.sessionStorage.removeItem('pname')
  //     // return true
  //   }
  // }
  // // 如果跳转的路径不是登录页
  // if (to.path !== `/login` && to.path !== '/') {
  //   // 并且没有session
  //   if (!window.sessionStorage.getItem(`userid`)) {
  //     Toast.fail('未登录状态，禁止访问，请先登录！')
  //     return `/login`
  //   }
  // }
  // return true
})
export default router
